const path = require('path');

module.exports = {
  lintOnSave: false,
  publicPath: './',
  outputDir: 'dist',

  // 关闭热重载，解决文件修改导致的重启
  devServer: {
    hot: false,        // 禁用热模块替换（HMR）
    liveReload: false  // 禁用自动刷新页面（可选，根据需求保留）
  },

  pluginOptions: {
    electronBuilder: {
      mainProcessFile: 'src/background.js',
      nodeIntegration: true,
      builderOptions: {
        asar: true,
        files: ["**/*"],
        asarUnpack: ['public/assets/item.json'],
        extraResources: [
          { from: "python_env", to: "python_env" },
          { from: "detect_game.py", to: "." },
          { from: "public/assets/item.json", to: "public/assets/item.json" }
        ],
        win: {
          target: [{ target: 'portable', arch: ['x64'] }],
          icon: path.join(__dirname, 'public', 'assets', 'logo.png'),
          requestedExecutionLevel: "requireAdministrator"
        },
        portable: {
          artifactName: 'WTZTool.exe',
          requestExecutionLevel: 'user'
        }
      }
    }
  },

  chainWebpack: config => {
    config.output
      .filename('js/[name].[hash].js')
      .chunkFilename('js/[name].[hash].js');

    config.plugin('html').tap(args => {
      args[0].publicPath = './';
      return args;
    });
  }
};